<?xml version="1.0" encoding="UTF-8"?><d:tdl xmlns="http://www.w3.org/1999/xhtml" xmlns:b="http://www.backbase.com/2006/btl" xmlns:bb="http://www.backbase.com/2006/client"  xmlns:d="http://www.backbase.com/2006/tdl" >

	<d:namespace name="http://www.backbase.com/2006/btl">

		<d:uses element="visualElement positionElement dimensionElement containerElement" src="../visualElement/visualElement.xml"/>
		<d:uses element="labelImplementor" src="../label/label.xml"/>
		<d:uses element="focusableElement" src="../focus/focus.xml"/>

		<d:element name="treeBase" extends="b:positionElement b:dimensionElement b:containerElement b:focusableElement" abstract="true">
			

			<d:resource type="text/javascript"><![CDATA[btl.treeBase = {};

//============================ btl.treeBase.handleMouseDownEvent =================
btl.treeBase.handleMouseDownEvent = function btl_treeBase_handleMouseDownEvent(oController, eEvent){
	var oTree = oController.getProperty('tree');

	if(oTree){
		var sSelectType = oTree.getAttribute('selectType');

		// when ctrl is pressed
		var bCtrl = !bb.browser.opera && navigator.platform.indexOf('Mac') != -1 ? eEvent.metaKey : eEvent.ctrlKey;
		if( ( sSelectType == 'multiple' || sSelectType == 'single' ) && bCtrl ) {
			// if selected: deselect
			if ( oController.getProperty('selected') )
				oController.removeAttribute('selected');
			// if not: select
			else
				oController.setAttribute('selected', 'true');
		} else {
			if (sSelectType == 'multiple') {
				if ( oController.getProperty('selected') ) {
					var aSelected = oTree.getProperty('selectedNodes');
					for (var i = 0, iMax = aSelected.length; i < iMax ; i++ ){
						if (aSelected[i] != oController)
							aSelected[i].setProperty('selected', false);
					}
				} else {
					oTree.clearSelection();
					oController.setProperty('selected', true);
				}
			} else {
				oController.setProperty('selected', true);
			}
		}
	}
};

btl.treeBase.setExclusiveSelection = function btl_treeBase_setExclusiveSelection(oTree, oController){
	var aSelected = oTree.getProperty('selectedNodes');
	for (var i = 0, iMax = aSelected.length; i < iMax ; i++ ){
		if (aSelected[i] != oController)
			aSelected[i].removeAttribute('selected')
	}

	if ( !btl.isTrueValue('selected', oController.getAttribute('selected')))
		oController.setAttribute('selected', 'selected');
};

btl.treeBase.setAdditionalSelection = function btl_treeBase_setAdditionalSelection(oTree, oController){
	var aSelected = oTree.getProperty('selectedNodes');
	for (var i = 0, iMax = aSelected.length; i < iMax ; i++ )
		if (aSelected[i] != oController)
			aSelected[i].removeAttribute('selected')
		oController.setAttribute('selected', 'selected');
};
//=============================== btl.treeBranchBase ===============================
btl.treeBranchBase = {};

btl.treeBranchBase.setProperIcon = function(oItem, oIconEl) {
	var sIcon = "";
	if (!oIconEl) {return;}
	var sState = btl.isTrueValue("empty", oItem.getAttribute("empty")) ? "empty" : "";
	if (!sState) {
		sState = btl.isTrueValue("open", oItem.getAttribute("open")) ? "open" : "closed";
	}
	switch (sState) {
		case "open":
			if(oItem.hasAttribute('iconOpen')){
				sIcon = oItem.getProperty("iconOpen");
				oIconEl.style.backgroundImage = sIcon ? 'url(' + sIcon + ')' : '';
			} else if(oItem.hasAttribute('icon')){
				sIcon = oItem.getProperty("icon");
				oIconEl.style.backgroundImage = sIcon ? 'url(' + sIcon + ')' : '';
			}
			break;
		case "closed":
			if(oItem.hasAttribute('icon')){
				sIcon = oItem.getProperty("icon");
				oIconEl.style.backgroundImage = sIcon ? 'url(' + sIcon + ')' : '';
			}
			break;
		case "empty":
		 	if(oItem.hasAttribute('iconEmpty')){
				sIcon = oItem.getProperty("iconEmpty");
				oIconEl.style.backgroundImage = sIcon ? 'url(' + sIcon + ')' : '';
			} else if(oItem.hasAttribute('icon')){
				sIcon = oItem.getProperty("icon");
				oIconEl.style.backgroundImage = sIcon ? 'url(' + sIcon + ')' : '';
			}

			break;
	}
};
]]></d:resource>

			<d:attribute name="selectType" default="singleRequired">
				
			</d:attribute>

			<d:attribute name="direction" default="ltr">
				
				<d:mapper type="text/javascript"><![CDATA[
					if (value == 'rtl')
						bb.html.addClass( this.viewNode, 'btl-tree-rtl');
					else
						bb.html.removeClass( this.viewNode, 'btl-tree-rtl');
				]]></d:mapper>
			</d:attribute>

			<d:property name="descendants">
				
				<d:getter type="text/javascript"><![CDATA[
					var aChildren = this.getProperty('childNodes');
					var aDescendants = [];
					for(var i = 0, iMax = aChildren.length; iMax > i; i++){
						if(bb.instanceOf(aChildren[i], btl.namespaceURI, 'treeItem')){
							aDescendants[aDescendants.length] = aChildren[i];
							if(bb.instanceOf(aChildren[i], btl.namespaceURI, 'treeBranchBase'))
								aDescendants.push.apply(aDescendants, aChildren[i].getProperty('descendants'));
						}
					}
					return aDescendants;
				]]></d:getter>
			</d:property>

			<d:property name="elements">
				
				<d:getter type="text/javascript"><![CDATA[
					var aChildren = this.getProperty('childNodes');
					var aElements = [];
					for(var i = 0, iMax = aChildren.length; iMax > i; i++){
						if(bb.instanceOf(aChildren[i], btl.namespaceURI, 'treeItem'))
							aElements[aElements.length] = aChildren[i];
					}
					return aElements;
				]]></d:getter>
			</d:property>

			<d:property name="focusedNode">
				
				<d:setter type="text/javascript"><![CDATA[
					/*
						treeBase should not access a parentNode in the view since it should
						know nothing about the template structure.
					*/
					var
						oCurrentFocusedNode = this.getProperty('focusedNode'),
						oTargetNode;

					if(oCurrentFocusedNode && oCurrentFocusedNode.viewNode) {
						oTargetNode = oCurrentFocusedNode.getProperty('labelGate').parentNode;
						bb.html.removeClass(oTargetNode, 'btl-treeItem-focus');
					}

					this._['_focusedNode'] = value;

					if(value){
						oTargetNode = value.getProperty('labelGate').parentNode;
						bb.html.addClass(oTargetNode, 'btl-treeItem-focus');
					}
				]]></d:setter>
			</d:property>

			<d:property name="selectedNode">
				
				<d:getter type="text/javascript"><![CDATA[
					if (this._['_selectedNodes'] != null)
						return this._['_selectedNodes'][0] || null;
					var oSelectedNode = null;
					var aElements = this.getProperty('elements');
					for (var i = 0, iMax = aElements.length; !oSelectedNode && i < iMax; i++)
						oSelectedNode = aElements[i].getProperty('selectedNode');
					if (!oSelectedNode)
						this._['_selectedNodes'] = []; // cache if no selected nodes
					return oSelectedNode;
				]]></d:getter>
			</d:property>

			<d:property name="selectedNodes">
				
				<d:getter type="text/javascript"><![CDATA[
					if (this._['_selectedNodes'] != null)
						return this._['_selectedNodes'];
					var aSelectedNodes = [];
					var aElements = this.getProperty('elements');
					for (var i = 0, iMax = aElements.length ; i < iMax ; i++) {
						var rv = aElements[i].getProperty('selectedNodes');
						aSelectedNodes.push.apply(aSelectedNodes, rv);
					}
					this._['_selectedNodes'] = aSelectedNodes;
					return aSelectedNodes;
				]]></d:getter>
			</d:property>

			<d:method name="resetSelectionCache">
				
				<d:body type="text/javascript"><![CDATA[
					this._['_selectedNodes'] = null;
				]]></d:body>
			</d:method>

			<d:method name="clearSelection">
				
				<d:body type="text/javascript"><![CDATA[
					var aSelectedNodes = this.getProperty('selectedNodes');
					var start = this.getAttribute('selectType') == 'singleRequired' ? 1 : 0;
					for (var i = start, iMax = aSelectedNodes.length ; i < iMax ; i++)
						aSelectedNodes[i].removeAttribute('selected');
				]]></d:body>
			</d:method>

			<d:handler event="DOMNodeInsertedIntoDocument" type="text/javascript"><![CDATA[
				bb.html.disableUserSelect(this.viewNode);

				var sSelectType = this.getAttribute('selectType');
				var oSelected = this.getProperty('selectedNode');

				// TODO: un-select elements if multiple elements have been selected in single mode?

				// TODO: this should not trigger select event actually
				var aElements = this.getProperty('elements');
				if ( sSelectType == 'singleRequired' && !oSelected && aElements.length ) {
					aElements[0].setAttribute('selected', 'true');
					oSelected = aElements[0];
				}

				var oFocusedNode = oSelected || aElements[0] || null;
				this.setProperty('focusedNode', oFocusedNode);
				if( bb.browser.ie){
					var oC = this;
					var func = function(){oC.__focused = false;}
					this.addEventListener('mouseup', func, false);
					this.addEventListener('mouseleave', func, false);
				}
			]]></d:handler>

			<d:handler event="mousedown" type="text/javascript"><![CDATA[
				var oController = event.target;

				while(oController != this && !bb.instanceOf(oController, btl.namespaceURI, 'treeItem')){
					oController = oController.getProperty('parentNode');
				}

				// this first check prevents the branch from opening when anything but the icon is clicked
				if(bb.selector.queryAncestor(event.viewTarget, '.btl-dataTree-selectAndToggle', oController.viewNode)){
					// do nothing
				} else if (bb.selector.queryAncestor(event.viewTarget, '.btl-dataTree-toggleOpenClose', oController.viewNode) && !btl.isTrueValue("empty", oController.getAttribute("empty"))) {
					if(btl.isTrueValue('open', oController.getAttribute('open'))){
						oController.setAttribute('open', 'false');
					} else {
						oController.setAttribute('open', 'true');
					}
				}
				if(bb.instanceOf(oController, btl.namespaceURI, 'treeItem') && (bb.selector.queryAncestor(event.viewTarget, '.btl-dataTree-selectAndToggle', oController.viewNode) || !bb.selector.queryAncestor(event.viewTarget, '.btl-dataTree-toggleOpenClose', oController.viewNode))) {
					this.setProperty('focusedNode', oController);
					if(!this.__focused){
						if( bb.browser.webkit || bb.browser.gecko){
							// Position focusElement at mouse position to avoid jump when top of tree is scrolled out of view
							this.getProperty('focusElement').style.top = oController.viewNode.offsetTop + 'px';
						}
						this.focus();
					}
					this.__focused = true;
					bb.html.scrollIntoView(oController.viewNode.firstChild);
					event.preventDefault();
				}
			]]></d:handler>
			<d:handler event="blur" type="text/javascript"><![CDATA[
				if(!bb.browser.ie) this.__focused = false;
			]]></d:handler>

			<d:handler event="keydown" type="text/javascript"><![CDATA[
				var oController = event.target;
				while(oController != this && !bb.instanceOf(oController, btl.namespaceURI, 'treeItem')){
					oController = oController.getProperty('parentNode');
				}
				if((oController == this) || bb.instanceOf(oController, btl.namespaceURI, 'treeItem')) {
					var oFocusedNode = this.getProperty('focusedNode');
					var oTargetNode;
					var keyIdent = event.keyIdentifier;

					if(this.getAttribute('direction') == 'rtl') {
						if(keyIdent == "Right")
							keyIdent = "Left";
						else if(keyIdent == "Left")
							keyIdent = "Right";
					}
					var bCtrl = navigator.platform.indexOf('Mac') != -1 ? event.metaKey || event.ctrlKey : event.ctrlKey;
					switch(keyIdent)
					{
						case "Up":
							oTargetNode = oFocusedNode.getProperty('previousSibling');
							while(oTargetNode && !bb.instanceOf(oTargetNode, btl.namespaceURI, 'treeItem')) {
								oTargetNode = oTargetNode.getProperty('previousSibling');
							}

							while(oTargetNode && bb.instanceOf(oTargetNode, btl.namespaceURI, 'treeBranchBase')
								  && btl.isTrueValue('open', oTargetNode.getAttribute('open')) && oTargetNode.getProperty('lastChild')) {
								var oChildNode = oTargetNode.getProperty('lastChild');
								while(oChildNode && !bb.instanceOf(oChildNode, btl.namespaceURI, 'treeItem')) {
									oChildNode = oChildNode.getProperty('previousSibling');
								}
								if(oChildNode) {
									oTargetNode = oChildNode;
								}
								else {
									break;
								}
							}

							oTargetNode = oTargetNode || oFocusedNode.getProperty('parentNode');

							if(oTargetNode && (oTargetNode != this)) {
								this.setProperty('focusedNode', oTargetNode);
								bb.html.scrollIntoView( oTargetNode.viewNode.firstChild);
								if(!bCtrl) {
									this.clearSelection();
									oTargetNode.setAttribute('selected', 'true');
								}
							}
							event.preventDefault();
						break;

						case "Down":
							var bComplete = true;
							if( bb.instanceOf(oFocusedNode, btl.namespaceURI, 'treeBranchBase') && btl.isTrueValue('open', oFocusedNode.getAttribute('open'))) {
								oTargetNode = oFocusedNode.getProperty('firstChild');
							}

							oTargetNode = oTargetNode || oFocusedNode;

							while((oTargetNode == oFocusedNode) || ((oTargetNode !=this) && !(bComplete && (bb.instanceOf(oTargetNode, btl.namespaceURI, 'treeLeafBase') || bb.instanceOf(oTargetNode, btl.namespaceURI, 'treeBranchBase'))))) {
								oTargetNode = (bComplete = true, oTargetNode.getProperty('nextSibling')) || (bComplete = false, oTargetNode.getProperty('parentNode'));
							}

							if(oTargetNode && (oTargetNode != this)) {
								this.setProperty('focusedNode', oTargetNode);
								bb.html.scrollIntoView( oTargetNode.viewNode.firstChild);
								if(!bCtrl) {
									this.clearSelection();
									oTargetNode.setAttribute('selected', 'true');
								}
							}
							event.preventDefault();
						break;

						case "Right":
							if(bb.instanceOf(oFocusedNode, btl.namespaceURI, 'treeBranchBase') && !bCtrl) {
								if(!btl.isTrueValue('open', oFocusedNode.getAttribute('open'))){
									if (!btl.isTrueValue("empty", oFocusedNode.getAttribute("empty"))) {
										oFocusedNode.setAttribute('open', 'true');
									}
								} else {
									if(oTargetNode = oFocusedNode.getProperty('firstChild')) {
										this.setProperty('focusedNode', oTargetNode);
										this.clearSelection();
										oTargetNode.setAttribute('selected', 'true');
									}
								}
							}
						break;

						case "Left":
							if(!bCtrl) {
								if(bb.instanceOf(oFocusedNode, btl.namespaceURI, 'treeBranchBase') && btl.isTrueValue('open', oFocusedNode.getAttribute('open'))) {
									if (!btl.isTrueValue("empty", oFocusedNode.getAttribute("empty"))) {
										oFocusedNode.setAttribute('open', 'false');
									}
									bb.html.scrollIntoView(oFocusedNode.viewNode.firstChild);
								} else {
									oTargetNode = oFocusedNode.getProperty('parentNode');
									if(oTargetNode != this) {
										this.setProperty('focusedNode', oTargetNode);
										this.clearSelection();
										oTargetNode.setAttribute('selected', 'true');
										bb.html.scrollIntoView(oTargetNode.viewNode.firstChild);
									}
								}
							}
						break;

						case "Enter":
						case "U+0020":
							oFocusedNode.setAttribute('selected', 'true');
						break;
					}
				}
			]]></d:handler>

			<d:handler event="mousedown" type="text/javascript"><![CDATA[
				var oController = event.target;
				while (oController != this && !bb.instanceOf(oController, btl.namespaceURI, 'treeItem'))
					oController = oController.getProperty('parentNode');

				if (bb.selector.queryAncestor(event.viewTarget, '.btl-dataTree-selectAndToggle', oController.viewNode) ||
						bb.instanceOf(oController, btl.namespaceURI, 'treeLeafBase')) {

					btl.treeBase.handleMouseDownEvent(oController, event);
				}
			]]></d:handler>


			<d:handler event="click" type="text/javascript"><![CDATA[
				var oController = event.target;
				while (oController != this && !bb.instanceOf(oController, btl.namespaceURI, 'treeItem'))
					oController = oController.getProperty('parentNode');

				if (bb.selector.queryAncestor(event.viewTarget, '.btl-dataTree-selectAndToggle', oController.viewNode) ||
						bb.instanceOf(oController, btl.namespaceURI, 'treeLeafBase')) {

					// included to prevent the visible focus border disappearing in Opera 9
					if (bb.browser.opera)
						event.preventDefault();
				}
			]]></d:handler>

			<d:handler event="dblclick" type="text/javascript"><![CDATA[
				var oController = event.target;
				if (bb.selector.queryAncestor(event.viewTarget, '.btl-dataTree-selectAndToggle', oController.viewNode) &&
						!btl.isTrueValue("empty", oController.getAttribute("empty")))
					oController.setAttribute('open', (!btl.isTrueValue('open', oController.getAttribute('open'))).toString());
			]]></d:handler>
		</d:element>

		<!--
			select event only triggered in setSingleSelectedNode method of tree...
			- in case of not wanting the event triggered, just set the attributes/properties
			- one centralized place to execute selection mechanism
		-->

		<!-- GENERIC NODE -->

		<d:element name="treeItem" extends="b:visualElement b:labelImplementor" abstract="true">
			

			

			

			

			<d:attribute name="selected">
				
				<d:changer type="text/javascript"><![CDATA[
					var oTree = this.getProperty('tree');

					if(oTree) {
						if ( btl.isTrueValue(name, value) ){
							// set visible stuff

							if (oTree.getAttribute('selectType') != 'multiple') {
								// make sure only one item is selected
								var aSelectedNodes = oTree.getProperty('selectedNodes');
								for (var i = 0, iMax = aSelectedNodes.length ; i < iMax ; i++)
									if (aSelectedNodes[i] != this)
										aSelectedNodes[i].removeAttribute('selected');
							}

							// open all ancestor elements
							var aAncestors = this.getProperty('ancestors');
							for (var i = 0, iMax = aAncestors.length; i < iMax; i++){
								if(bb.instanceOf(aAncestors[i], btl.namespaceURI, 'treeBranchBase'))
									aAncestors[i].setAttribute('open', 'true');
							}

							bb.command.fireEvent(this, 'select', false, false);
						} else {
							// depending on tree selectiontype
							var sSelectType = oTree.getAttribute('selectType');
							if ( sSelectType != 'singleRequired' || ( sSelectType == 'singleRequired' && oTree.getProperty('selectedNodes').length ) ) {

								bb.command.fireEvent(this, 'deselect', false, false);
							}
						}
					}
					this.resetSelectionCache();	// reset cache
				]]></d:changer>
			</d:attribute>

			<d:property name="selected">
				<d:setter type="text/javascript"><![CDATA[
					if(value == true)
						this.setAttribute('selected', 'true');
					else
						this.removeAttribute('selected');
				]]></d:setter>
				<d:getter type="text/javascript"><![CDATA[
					return btl.isTrueValue('selected', this.getAttribute('selected'));
				]]></d:getter>
			</d:property>

			<d:property name="selectedNode">
				
				<d:getter type="text/javascript"><![CDATA[
					if (this._['_selectedNodes'] != null)
						return this._['_selectedNodes'][0] || null;
					var oSelectedNode = this.getProperty('selected') ? this : null;
					var aElements = this.getProperty('elements');
					for (var i = 0, iMax = aElements.length; !oSelectedNode && i < iMax; i++)
						oSelectedNode = aElements[i].getProperty('selectedNode');
					if (!oSelectedNode)
						this._['_selectedNodes'] = []; // cache if no selected nodes
					return oSelectedNode;
				]]></d:getter>
			</d:property>

			<d:property name="selectedNodes">
				
				<d:getter type="text/javascript"><![CDATA[
					if (this._['_selectedNodes'] != null)
						return this._['_selectedNodes'];
					var aSelectedNodes = this.getProperty('selected') ? [this] : [];
					var aElements = this.getProperty('elements');
					for (var i = 0, iMax = aElements.length ; i < iMax ; i++) {
						var rv = aElements[i].getProperty('selectedNodes');
						aSelectedNodes.push.apply(aSelectedNodes, rv);
					}
					this._['_selectedNodes'] = aSelectedNodes;
					return aSelectedNodes;
				]]></d:getter>
			</d:property>

			<d:property name="elements">
				
				<d:getter type="text/javascript"><![CDATA[
					var aChildren = this.getProperty('childNodes');
					var aElements = [];
					for(var i = 0, iMax = aChildren.length; iMax > i; i++){
						if(bb.instanceOf(aChildren[i], btl.namespaceURI, 'treeItem'))
							aElements[aElements.length] = aChildren[i];
					}
					return aElements;
				]]></d:getter>
			</d:property>

			<d:property name="ancestors">
				<d:getter type="text/javascript"><![CDATA[
					var oParent = this.getProperty('parentNode');
					var aAncestors = [];

					if(bb.instanceOf(oParent, btl.namespaceURI, 'treeItem')) {
						aAncestors[0] = oParent;
						aAncestors.push.apply(aAncestors, oParent.getProperty('ancestors'));
					} else if(bb.instanceOf(oParent, btl.namespaceURI, 'treeBase')) {
						aAncestors[0] = oParent;
					}
					return aAncestors;
				]]></d:getter>
			</d:property>

			<d:property name="tree">
				<d:getter type="text/javascript"><![CDATA[
					var oParent = this.getProperty('parentNode');
					while (oParent.getProperty('nodeType') == 1 &&
							!oParent.instanceOf(btl.namespaceURI, 'treeBase')) {
						oParent = oParent.getProperty('parentNode');
					}
					return oParent.getProperty('nodeType') == 1 ? oParent : null;
				]]></d:getter>
			</d:property>

			<d:method name="resetSelectionCache">
				
				<d:body type="text/javascript"><![CDATA[
					this._['_selectedNodes'] = null;
					var oParent = this.getProperty('parentNode');
					if (bb.instanceOf(oParent, btl.namespaceURI, 'treeItem') ||
						bb.instanceOf(oParent, btl.namespaceURI, 'treeBase'))
						oParent.resetSelectionCache();
				]]></d:body>
			</d:method>

			<d:handler event="DOMNodeInsertedIntoDocument" type="text/javascript"><![CDATA[
				if(btl.isTrueValue('selected', this.getAttribute('selected'))){
					var aAncestors = this.getProperty('ancestors');
					for (var i = 0, iMax = aAncestors.length; i < iMax; i++){
						if(bb.instanceOf(aAncestors[i], btl.namespaceURI, 'treeBranchBase'))
							aAncestors[i].setAttribute('open', 'true');
					}
				}
			]]></d:handler>

			<d:handler event="DOMNodeInserted" type="text/javascript"><![CDATA[
				this.resetSelectionCache();
			]]></d:handler>

			<d:handler event="DOMNodeRemoved" type="text/javascript"><![CDATA[
				this.resetSelectionCache();
			]]></d:handler>
		</d:element>

		<!-- treeBranch is nothing more than a leafnode that can open and looks a bit different -->
		<d:element name="treeBranchBase" extends="b:treeItem" abstract="true">
			

			<!-- ATTRIBUTES -->
			<d:attribute name="open" default="false">
				
				<d:changer type="text/javascript"><![CDATA[
					// if it has to be opened
					if ( btl.isTrueValue(name, value) ) {
						var aAncestors = this.getProperty('ancestors');
						for (var i = 0, iMax = aAncestors.length; i < iMax; i++){
							if(bb.instanceOf(aAncestors[i], btl.namespaceURI, 'treeBranchBase'))
								aAncestors[i].setAttribute('open', 'true');
						}
						bb.command.fireEvent(this, 'open', false, false);
					}
					// if it has to be closed
					else {
						// shift selection if one of the descendants is selected if selectType = singleRequired
						var oTree = this.getProperty('tree');
						var sSelectType = oTree.getAttribute('selectType');
						var aDescendants = this.getProperty('descendants');
						var aSelected = [];

						for (var i = 0, iMax = aDescendants.length ; i < iMax ; i++ ){
							if( btl.isTrueValue('selected', aDescendants[i].getAttribute('selected')) )
								aSelected[aSelected.length] = aDescendants[i];
						}

						if ( sSelectType == 'singleRequired' && aSelected.length )
							this.setAttribute('selected', 'selected');

						else if ( sSelectType == 'single' || sSelectType == 'multiple' ) {
							for (var i = 0, iMax = aSelected.length; iMax > i ; i++)
								aSelected[i].removeAttribute('selected');
						}

						bb.command.fireEvent(this, 'close', false, false);
					}
				]]></d:changer>
			</d:attribute>

			<d:attribute name="empty">
				
			</d:attribute>

			<d:attribute name="icon" onmap="btl.treeBranchBase.setProperIcon(this, btl.treeBranch.getIconElement(this));">
				
			</d:attribute>

			<d:attribute name="iconOpen" onmap="btl.treeBranchBase.setProperIcon(this, btl.treeBranch.getIconElement(this));">
				
			</d:attribute>

			<d:attribute name="iconEmpty" onmap="btl.treeBranchBase.setProperIcon(this, btl.treeBranch.getIconElement(this));">
				
			</d:attribute>

			<d:property name="icon" onget="return bb.uri.resolveUri(bb.callMethod(this, 'getAttribute', [name] ), bb.getProperty(this, 'baseURI'));" onset="bb.callMethod(this,'setAttribute', [name,  value] );">
				
			</d:property>

			<d:property name="iconOpen" onget="return bb.uri.resolveUri(bb.callMethod(this, 'getAttribute', [name] ), bb.getProperty(this, 'baseURI'));" onset="bb.callMethod(this,'setAttribute', [name,  value] );">
				
			</d:property>
			<d:property name="iconEmpty" onget="return bb.uri.resolveUri(bb.callMethod(this, 'getAttribute', [name] ), bb.getProperty(this, 'baseURI'));" onset="bb.callMethod(this,'setAttribute', [name,  value] );">
				
			</d:property>

			<d:property name="descendants">
				
				<d:getter type="text/javascript"><![CDATA[
					var aChildren = this.getProperty('childNodes');
					var aDescendants = [];
					for(var i = 0, iMax = aChildren.length; iMax > i; i++){
						if(bb.instanceOf(aChildren[i], btl.namespaceURI, 'treeItem'))
							aDescendants[aDescendants.length] = aChildren[i];
						if(bb.instanceOf(aChildren[i], btl.namespaceURI, 'treeBranchBase'))
							aDescendants.push.apply(aDescendants, aChildren[i].getProperty('descendants'));
					}
					return aDescendants;
				]]></d:getter>
			</d:property>

			<d:property name="elements">
				
				<d:getter type="text/javascript"><![CDATA[
					var aChildren = this.getProperty('childNodes');
					var aElements = [];
					for(var i = 0, iMax = aChildren.length; iMax > i; i++){
						if(bb.instanceOf(aChildren[i], btl.namespaceURI, 'treeItem'))
							aElements[aElements.length] = aChildren[i];
					}
					return aElements;
				]]></d:getter>
			</d:property>
		</d:element>

		<d:element name="treeLeafBase" extends="b:treeItem" abstract="true">
			

			<d:attribute name="icon">
				
			</d:attribute>

			<d:property name="icon" onget="return bb.uri.resolveUri(bb.callMethod(this, 'getAttribute', [name] ), bb.getProperty(this, 'baseURI'));" onset="bb.callMethod(this,'setAttribute', [name,  value] );">
				
			</d:property>

			<d:property name="selectedNode">
				
				<d:getter type="text/javascript"><![CDATA[
					return this.getProperty('selected') ? this : null;
				]]></d:getter>
			</d:property>

			<d:property name="selectedNodes">
				
				<d:getter type="text/javascript"><![CDATA[
					return this.getProperty('selected') ? [this] : [];
				]]></d:getter>
			</d:property>

			<d:method name="resetSelectionCache">
				<d:body type="text/javascript"><![CDATA[
					this.getProperty('parentNode').resetSelectionCache();
				]]></d:body>
			</d:method>
		</d:element>
	</d:namespace>
</d:tdl>